public class Solution {
    public int maxProfit(int[] prices) {
        int len = prices.length;
        int sum = 0;
        for(int i = 1; i < len; i++) {
            int t = prices[i] - prices[i - 1];
            if(t > 0) {
                sum += t;
            }
        }
        return sum;
    }
}
